package cn.goodym.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.goodym.mapper.CasePlanMapper;
import cn.goodym.po.CasePlan;
import cn.goodym.po.CasePort;
import cn.goodym.po.PagingVO;
import cn.goodym.service.CasePlanService;

/**
 * 测试计划实现层
 * 
 * @author Administrator
 * 
 */
@Service("casePlanService")
public class CasePlanServiceImp implements CasePlanService {

	@Autowired
	private CasePlanMapper casePlanMapper;

	@Override
	public Boolean save(CasePlan casePlan) {
		
		CasePlan cp = casePlanMapper.selectByPrimaryKey(casePlan.getId());
		if (cp == null) {
			casePlanMapper.insert(casePlan);
			return true;
		}
		return false;
	}

	@Override
	public int getCount() {
		return casePlanMapper.countByExample();
	}

	@Override
	public List<CasePlan> findByPaging(Integer page) {
		PagingVO pagingVO = new PagingVO();
		pagingVO.setToPageNo(page);
		List<CasePlan> list = casePlanMapper.findByPaging(pagingVO);
		return list;
	}

	@Override
	public void removeById(Integer id) {
		casePlanMapper.deleteByPrimaryKey(id);
	}

	@Override
	public CasePlan findById(Integer id) {
		return casePlanMapper.selectByPrimaryKey(id);
	}

	@Override
	public void updateById(CasePlan casePlan) {
		casePlanMapper.updateByPrimaryKey(casePlan);
	}

	@Override
	public List<CasePlan> findByName(String planName) {
		List<CasePlan> list = casePlanMapper.selectByExample(planName);
		return list;
	}

}
